/*
 * Copyright 2002-2019 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.context;

import org.springframework.beans.factory.Aware;
import org.springframework.core.io.ResourceLoader;

/**
 * Interface to be implemented by any object that wishes to be notified of the
 * {@link ResourceLoader} (typically the ApplicationContext) that it runs in.
 * This is an alternative to a full {@link ApplicationContext} dependency via
 * the {@link org.springframework.context.ApplicationContextAware} interface.
 * <br/>接口由希望得到ResourceLoader(通常是ApplicationContext)通知的任何对象实现。
 * 这是一个通过ApplicationContextAware接口的完整ApplicationContext依赖的替代方案。
 *
 * <p>Note that {@link org.springframework.core.io.Resource} dependencies can also
 * be exposed as bean properties of type {@code Resource}, populated via Strings
 * with automatic type conversion by the bean factory. This removes the need for
 * implementing any callback interface just for the purpose of accessing a
 * specific file resource.
 * <br/>注意，Resource依赖关系也可以公开为Resource类型的bean属性，由bean工厂通过自动类型
 * 转换的字符串填充。 这样就不需要仅仅为了访问特定的文件资源而实现任何回调接口。
 *
 * <p>You typically need a {@link ResourceLoader} when your application object has to
 * access a variety of file resources whose names are calculated. A good strategy is
 * to make the object use a {@link org.springframework.core.io.DefaultResourceLoader}
 * but still implement {@code ResourceLoaderAware} to allow for overriding when
 * running in an {@code ApplicationContext}. See
 * {@link org.springframework.context.support.ReloadableResourceBundleMessageSource}
 * for an example.
 * <br/>当您的应用程序对象必须访问各种计算了其名称的文件资源时，通常需要一个ResourceLoader。
 * 一个好的策略是让对象使用org.springframework.core.io.DefaultResourceLoader，但仍然实现
 * ResourceLoaderAware，以允许在ApplicationContext中运行时重写。 ReloadableResourceBundleMessageSource是一个例子。
 *
 * <p>A passed-in {@code ResourceLoader} can also be checked for the
 * {@link org.springframework.core.io.support.ResourcePatternResolver} interface
 * and cast accordingly, in order to resolve resource patterns into arrays of
 * {@code Resource} objects. This will always work when running in an ApplicationContext
 * (since the context interface extends the ResourcePatternResolver interface). Use a
 * {@link org.springframework.core.io.support.PathMatchingResourcePatternResolver} as
 * default; see also the {@code ResourcePatternUtils.getResourcePatternResolver} method.
 * <br/>还可以检查传入的ResourceLoader是否为ResourcePatternResolver接口，并进行相应的转换，
 * 以便将资源模式解析为Resource对象数组。 当在ApplicationContext中运行时，这将始终有效(因为上下文
 * 接口扩展了ResourcePatternResolver接口)。 使用org.springframework.core.io.support.PathMatchingResourcePatternResolver
 * 作为默认值; 请参见ResourcePatternUtils。 getResourcePatternResolver方法。
 *
 * <p>As an alternative to a {@code ResourcePatternResolver} dependency, consider
 * exposing bean properties of type {@code Resource} array, populated via pattern
 * Strings with automatic type conversion by the bean factory at binding time.
 * <br/>作为ResourcePatternResolver依赖项的替代方案，可以考虑公开Resource数组类型的bean属性，
 * 该属性通过模式String填充，在绑定时由bean工厂自动进行类型转换。
 *
 * @author Juergen Hoeller
 * @author Chris Beams
 * @since 10.03.2004
 * @see ApplicationContextAware
 * @see org.springframework.core.io.Resource
 * @see org.springframework.core.io.ResourceLoader
 * @see org.springframework.core.io.support.ResourcePatternResolver
 */
public interface ResourceLoaderAware extends Aware {

    /**
     * Set the ResourceLoader that this object runs in.
     * <br/>设置运行此对象的ResourceLoader。
     * <p>This might be a ResourcePatternResolver, which can be checked
     * through {@code instanceof ResourcePatternResolver}. See also the
     * {@code ResourcePatternUtils.getResourcePatternResolver} method.
     * <br/>这可能是一个ResourcePatternResolver，它可以通过instanceof ResourcePatternResolver
     * 进行检查。 请参见ResourcePatternUtils。 getResourcePatternResolver方法。
     * <p>Invoked after population of normal bean properties but before an init callback
     * like InitializingBean's {@code afterPropertiesSet} or a custom init-method.
     * Invoked before ApplicationContextAware's {@code setApplicationContext}.
     * <br/>在填充普通bean属性之后、在初始化回调(如InitializingBean的afterPropertiesSet或自定义初始化方法)
     * 之前调用。 在ApplicationContextAware的setApplicationContext之前调用。
     * @param resourceLoader the ResourceLoader object to be used by this object
     *                       <br/>该对象使用的resourceLoader对象
     * @see org.springframework.core.io.support.ResourcePatternResolver
     * @see org.springframework.core.io.support.ResourcePatternUtils#getResourcePatternResolver
     */
    void setResourceLoader(ResourceLoader resourceLoader);

}
